package com.pucheng.bracelet.viewmodel.bracelet

import androidx.lifecycle.MutableLiveData
import com.pucheng.bracelet.app.util.CacheUtil
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

class DoNotDisturbViewModel : BaseViewModel(){
    val startTime = MutableLiveData<String>().apply {
        value = CacheUtil.getDoNotDisturb().split("[-]".toRegex())[0]
    }

    val endTime = MutableLiveData<String>().apply {
        value = CacheUtil.getDoNotDisturb().split("[-]".toRegex())[1]
    }

    fun saveData() {
        if (startTime.value!!.length<2){
            startTime.value = "0"+startTime.value
        }
        if (endTime.value!!.length<2){
            endTime.value = "0"+endTime.value
        }
        CacheUtil.setDoNotDisturb("${startTime.value!!}-${endTime.value}")
    }
}